package cepicam.src.uc;

import cepicam.src.dao.AutoEcoleDAO;
import cepicam.src.domain.Adresse;
import cepicam.src.domain.AutoEcole;
import cepicam.src.domain.Utilisateur;

import java.sql.SQLException;
import java.util.ArrayList;

public class GestionAutoEcole {

	private ArrayList<AutoEcole> listEcoles;
	private AutoEcoleDAO ecoledao;
	
	private static GestionAutoEcole instance = new GestionAutoEcole();
	
	private GestionAutoEcole() {
		ecoledao = new AutoEcoleDAO();
	}
	
	public static GestionAutoEcole getInstance(){
		return instance;
	}
	
	public ArrayList<AutoEcole> listerEcoles(){
		
		ArrayList<AutoEcole> listecol = null;
		ecoledao = new AutoEcoleDAO();
		listecol = ecoledao.listerAvecAdresse();
		return listecol;
	}
	
	public AutoEcole ajouterAutoEcole(AutoEcole ecole, Adresse adrFac, Adresse adrOFF) {

		if(adrFac.getType_adr() != adrOFF.getType_adr()){
			ecole = ecoledao.createAvecAdresse(ecole, adrFac, adrOFF);
			return ecole;
		} else
			// trow new exception
		
		return null;
		
	}
	
	public AutoEcole supprimerAutoEcole(AutoEcole ecole){
		ecole = ecoledao.delete(ecole);
		return ecole;
	}
	
	public AutoEcole modifierAutoEcole(AutoEcole ecole){
		ecole = ecoledao.update(ecole);
		return ecole;
	}
	
	
	
}
